﻿@model   CategoryDTO
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<section class="layui-larry-box">
    <div class="larry-personal">
        <header class="larry-personal-tit">
            <span>修改商品类别</span>
        </header><!-- /header -->
        <div class="larry-personal-body clearfix">
            <form class="layui-form col-lg-5" id="form">
                <input type="hidden" name="Id" value="@Model.Id" />
                <div class="layui-form-item">
                    <label class="layui-form-label">商品类别名</label>
                    <div class="layui-input-block">
                        <input type="text" name="Name" value="@Model.Name" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入商品类别名">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
@section FooterScript{
    <script type="text/javascript">

            var appConfig = {};

            layui.use(['form'], function () {
                var form = layui.form();
                form.on("submit(demo1)", function (data) {
                    var json = $("#form").serialize();
                    $.ajax({
                        url: "/Category/Edit",
                        type: "post",
                        dataType: "json",
                        data: json,
                        success: function (res) {
                            if (res.status == "error") {
                                layer.msg(res.errorMsg, { icon: 2, time: 2000 });
                            }
                            else if (res.status == "ok") {
                                parent.location.reload();
                            } else {
                                layer.msg("错误", { icon: 2, time: 1500 });
                            }
                        },
                        error: function () {
                            layer.msg("请求出错");
                        }
                    });

                    return false;
                })
            });

    </script>
}

